/**
 * 
 */
package photosalvage.entity;

import javax.inject.Singleton;

import com.google.inject.AbstractModule;
import com.google.inject.persist.jpa.JpaPersistModule;

/**
 * @author shumpei
 *
 */
public class EntityModule extends AbstractModule {
	private static final String PERSISTENCE_UNIT_NAME = "photosalvage";

	static final Class<?>[] ENTITY_CLASSES = new Class<?>[] {
		Photo.class
	};
	static final Class<?>[] REPOSITORY_CLASSES = new Class<?>[] {
		PhotoRepository.class
	};
	/* (non-Javadoc)
	 * @see com.google.inject.AbstractModule#configure()
	 */
	@Override
	protected void configure() {
		for (Class<?> resourceClass : ENTITY_CLASSES) {
			bind(resourceClass);
		}
		for (Class<?> repositoryClass : REPOSITORY_CLASSES) {
			bind(repositoryClass).in(Singleton.class);
		}
		install(new JpaPersistModule(PERSISTENCE_UNIT_NAME));
	}
}
